
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head >
  <title>Ajax test call</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <script type="text/javascript" src="../js/jquery-min-2.1.3.js" ></script>
  <script type="text/javascript" src="../js/jquery.class.min.js" ></script>
  <script type="text/javascript" src="../js/md5-min.js" ></script>
  <script type="text/javascript" src="../js/digest-auth.js" ></script>
   
  <script type="text/javascript">
    var digestAuth = new pl.arrowgroup.DigestAuthentication(
            {
              onSuccess : function(response){
                $("#response").html(response);
              },
              onFailure : function(response){
                $("#response").html('Invalid credentials !!!');
              },
              cnonce : 'testCnonce'
            }
    );
    function callREST(){
      digestAuth.setCredentials($('#user').val(),$('#password').val());
      digestAuth.call('/api/v1/login');
    }
  </script>
</head>
<body>
<div>
  <h3>Test example of Digest Authentication using Ajax request and Spring Security</h3>
</div>
<div>
  <form >
    <p>User <input id="user" type="text" name="username" value="chuanbao"/></p>
    <p>Password <input id="password" type="text" name="password" value="123"/></p>
    <p> <button onclick="callREST(); return false;" >Login</button>
  </form>
</div>
<div id="response">
</div>
</body>
</html>
